<template>
  <div id="app">
    <h3>{{ title }}</h3>
    <input type="text" :value="num" @input="changeNum">
    <hr>
    <HelloWorld/>
    <hr>
    <button @click="RandomNum">随机数字</button><br>
    <hr>
    <Hello></Hello>
    <hr>
    <world></world>
  </div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'
import Hello from './components/Hello.vue'
import world from './components/world.vue'
import { mapState,mapMutations} from 'vuex'
export default {
  name: 'App',
  data () {
    return {
      
    }
  },
  components: {
    HelloWorld,
    Hello,
    world
  },
  computed: {
   ...mapState(['num','title']),
  },
  methods: {
     changeNum(e){
       this.$store.commit('reset',+e.target.value)
     },
     RandomNum(){
       let randomNum = Math.floor(Math.random()*100)
       this.$store.commit('reset',randomNum)
     },
     ...mapMutations ('user',['Addcount'])
  }
}
</script>

<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
